package com.permisos
{
	import com.system.ControlSystem;

	import mx.collections.ArrayCollection;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.mxml.RemoteObject;

	public class Permiso
	{

		private var ro:RemoteObject;
		public var value:ArrayCollection;

		public function Permiso(pk:int){
			inicializaRemoteObject();
			ro.verificaPermiso(pk);
		}

		private function inicializaRemoteObject():void{
			ro = new RemoteObject("php");
			ro.source = "catalogos.Permisos";
			ro.endpoint = ControlSystem.getInstancia().endPoint;
			ro.addEventListener(ResultEvent.RESULT,onResult);
			ro.addEventListener(FaultEvent.FAULT,onFault);
		}

		private function onResult(event:Object):void{
			value = new ArrayCollection(event.result);
			ControlSystem.getInstancia().permisos = value;
		}

		private function onFault(event:FaultEvent):void{
			value = new ArrayCollection();
		}

	}
}